import {
  Controller,
  Get,
  Post,
  Body,
  Put,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { GeographService } from './geograph.service';
import { CreateGeographDto } from './dto/create-geograph.dto';
import { UpdateGeographDto } from './dto/update-geograph.dto';
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';

@Controller('geograph')
@ApiTags('地理位置')
export class GeographController {
  constructor(private readonly geographService: GeographService) {}

  @Post()
  create(@Body() createGeographDto: CreateGeographDto) {
    return this.geographService.create(createGeographDto);
  }

  @Get('/skip')
  @ApiOperation({
    description: '分页查询地理服务信息',
    summary: '分页查询',
  })
  @ApiQuery({ name: 'size', description: '数据条数', required: true })
  @ApiQuery({ name: 'current', description: '当前页码', required: true })
  skipFind(@Query('current') current, @Query('size') size) {
    return this.geographService.skipFind(+current, +size);
  }

  @Get()
  findAll() {
    return this.geographService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.geographService.findOne(+id);
  }

  @Put(':id')
  update(
    @Param('id') id: string,
    @Body() updateGeographDto: UpdateGeographDto,
  ) {
    return this.geographService.update(updateGeographDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.geographService.remove(+id);
  }
}
